/*
 *  2004/5/14 created
 *
 */
package jaoso.framework.dao.hibernate;

import jaoso.framework.dao.BaseDAO;
import jaoso.framework.dao.MyQuery;
import jaoso.framework.dao.QueryManager;

import jaoso.framework.exception.DAOException;

import java.io.Serializable;

/**
 * @author edgeloner edgeloner@163.com
 * 
 *  
 */
public class QueryManagerImpl implements QueryManager
{
    /**
     * DOCUMENT ME!
     */
    private BaseDAO baseDAO;

    /**
     * DOCUMENT ME!
     * 
     * @param dao
     *            DOCUMENT ME!
     */
    public final void setBaseDAO(final BaseDAO dao)
    {
        baseDAO = dao;
    }

    /**
     * find object from database
     * 
     * @param myquery
     *            myquery
     * @return object array
     * @throws DAOException
     *             any error
     */
    public final Object[] find(final MyQuery myquery) throws DAOException
    {
        return baseDAO.findEntity(myquery);
    }

    /**
     * find object from database
     * 
     * @param myquery
     *            myquery
     * @return object array
     * @throws DAOException
     *             any error
     */
    public final Object[] find(final String myquery) throws DAOException
    {
        return baseDAO.findEntity(myquery);
    }

    /**
     * find object from database
     * 
     * @param obj
     *            object
     * @param id
     *            primary key
     * @return object
     * @throws DAOException
     *             any error
     */
    public final Object findByPK(final Object obj, final Serializable id)
            throws DAOException
    {
        return baseDAO.loadEntity(obj, id);
    }
}